package com.rybbaby.tss.front.tssMemberReturnPremium.dao.imp;

import com.rybbaby.tss.core.web.dao.imp.GenericDao;
import com.rybbaby.tss.front.tssMemberReturnPremium.dao.IViewRefundListDao;
import com.rybbaby.tss.front.tssMemberReturnPremium.entity.ViewRefundList;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description 会员退费记录表数据库操作实现
 * 
 * @author 雷春琼
 * 
 * @createDate 2017-08-10 上午12:14:02
 */
@Repository
public class ViewRefundListDaoImp extends GenericDao<ViewRefundList> implements IViewRefundListDao {

    @Override
    public List<ViewRefundList> packageRefundList(String stuId) throws Exception {
        String sql = "select * from view_refund_list where stuId = ? and  paymentType in (1,3)";
        List<ViewRefundList> listBySql = this.findListBySql(sql, ViewRefundList.class, stuId);
        return listBySql;
    }

    @Override
    public List<ViewRefundList> paymentRefundList(String stuId) throws Exception {
        String sql = "SELECT\n" +
                "\tview_refund_list.*,\n" +
                "\tSUM(view_refund_list.amount) AS sumAmount\n" +
                "FROM\n" +
                "\tview_refund_list\n" +
                "WHERE\n" +
                "\tstuId = ?\n" +
                "AND paymentType NOT IN (1,2,3,7) \n" +
                "GROUP BY view_refund_list.paymentType";
        List<ViewRefundList> listBySql = this.findListBySql(sql, ViewRefundList.class, stuId);
        return listBySql;
    }

    @Override
    public List<ViewRefundList> depositRefundList(String stuId) throws Exception {
        String sql = "SELECT\n" +
                "\t*\n" +
                "FROM\n" +
                "\tview_refund_list\n" +
                "WHERE\n" +
                "\tstuId = ?\n" +
                "AND paymentType = '2'\n" +
                "AND depositStatus ='1'";
        List<ViewRefundList> listBySql = this.findListBySql(sql, ViewRefundList.class, stuId);
        return listBySql;
    }

    @Override
    public List<ViewRefundList> registeryFeeRefundList(String stuId) throws Exception {
        String sql = "SELECT\n" +
                "\t*\n" +
                "FROM\n" +
                "\tview_refund_list\n" +
                "WHERE\n" +
                "\tstuId = ?\n" +
                "AND paymentType = '7'";
        List<ViewRefundList> listBySql = this.findListBySql(sql, ViewRefundList.class, stuId);
        return listBySql;
    }

}
